#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Author : GUO Lin 
#
# Created on 2010-09-18.
# $Id$
#

from base_test import TestBase

from django.core.urlresolvers import reverse
from friday.apps.restos.models import Resto, Dish, _DEFAULT_RESTO_CATEGORY

class BaseRestoTest(TestBase):
    
    PRE_RESTO_NAME = "pre resto name"
    PRE_RESTO_DESC = "pre resto desc"
    PRE_RESTO_CATEGORY = _DEFAULT_RESTO_CATEGORY
    PRE_RESTO_ADDRESS  = "pre resto address"
    PRE_RESTO_CITY = "pre resto city"
    PRE_RESTO_POST_CODE = "pre resto post code"
    PRE_RESTO_ROUTE = "pre resto route"
    PRE_RESTO_TEL_1 = "pre resto tel 1"
    PRE_RESTO_TEL_2 = "pre resto tel 2"
    PRE_RESTO_WEBSITE = "http://www.google.com"
    PRE_RESTO_HOURS_1 = "pre resto hours 1"
    PRE_RESTO_HOURS_2 = "pre resto hours 2"
    PRE_RESTO_HOURS_3 = "pre resto hours 3"
    PRE_RESTO_PLACES  = 12
    
    def setUp(self):
        super(BaseRestoTest, self).setUp()
        self.reset_user_to_webmaster()
        self.pre_resto = self.__class__.create_pre_resto()
    
    def tearDown(self):
        resto = Resto.get_unique(self.pre_resto.id)
        if resto is not None:
            resto.delete()
        super(BaseRestoTest, self).tearDown()

    def view_url(self, id):
        return reverse("friday.view_resto", kwargs={"resto_id":id})
    
    @classmethod
    def create_pre_resto(cls):
        pre_data = cls.get_pre_resto_data()
        user = cls.get_current_user()
        pre_data["submitter"] = user
        resto = Resto.create(**pre_data)
        resto.save()
        return resto
        
    @classmethod
    def get_pre_resto_data(cls):
        pre_data = { "name"         : cls.PRE_RESTO_NAME,
                     "description"  : cls.PRE_RESTO_DESC,
                     "category"     : cls.PRE_RESTO_CATEGORY,
                     "address"      : cls.PRE_RESTO_ADDRESS,
                     "city"         : cls.PRE_RESTO_CITY,
                    #"geo_pt"       : "",
                     "post_code"    : cls.PRE_RESTO_POST_CODE,
                     "route"        : cls.PRE_RESTO_ROUTE,
                     "tel_1"        : cls.PRE_RESTO_TEL_1,
                     "tel_2"        : cls.PRE_RESTO_TEL_2,
                     "website"      : cls.PRE_RESTO_WEBSITE,
                     "hours_1"      : cls.PRE_RESTO_HOURS_1,
                     "hours_2"      : cls.PRE_RESTO_HOURS_2,
                     "hours_3"      : cls.PRE_RESTO_HOURS_3,
                     "places"       : cls.PRE_RESTO_PLACES, }
        return pre_data

    @classmethod        
    def get_update_resto_data(self):
        update_data = { "name"         : "resto test name",
                      "description"  : "resto test description",
                      "category"     : _DEFAULT_RESTO_CATEGORY,
                      "address"      : "resto test address",
                      "city"         : "resto test city",
                      #"geo_pt"       : "",
                      "post_code"    : "resto test post_code",
                      "route"        : "resto test route",
                      "tel_1"        : "resto test tel_1",
                      "tel_2"        : "resto test tel_2",
                      "website"      : "http://resto.test.address.com/",
                      "hours_1"      : "resto test hours_1",
                      "hours_2"      : "resto test hours_2",
                      "hours_3"      : "resto test hours_3",
                      "places"       : 10, }
        return update_data
    
#EOF